package com.wlhse.controller;


import com.wlhse.dto.getDto.AddTaskGetDto;
import com.wlhse.dto.getDto.StaffIDGetDto;
import com.wlhse.dto.inDto.SupervisionTaskDetailInDto;
import com.wlhse.service.TaskAddService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Api(value = "下达任务",tags = {"下达任务"})
@RestController("TaskAddController")
@RequestMapping("/api/v1")
public class TaskAddController {
    @Resource
    private TaskAddService taskAddService;

    @RequestMapping(value = "/task_add_area",method = RequestMethod.GET,produces ="application/json; charset=utf-8" )
    public String getArea(){
        return taskAddService.getArea();
    }

    @RequestMapping(value = "/task_add_user",method = RequestMethod.GET,produces ="application/json; charset=utf-8" )
    public String getUserName(HttpServletRequest request){
        return taskAddService.getUser(request);
    }

    @RequestMapping(value = "/task_add_person/{area}",method = RequestMethod.GET,produces ="application/json; charset=utf-8" )
    public String getPerson(@PathVariable("area") String area){
        return taskAddService.getPersonByArea(area);
    }

    @RequestMapping(value = "/task_add_getTaskByName",method = RequestMethod.POST,produces ="application/json; charset=utf-8" )
    public String getTask(@RequestBody(required = false) StaffIDGetDto staffIDList){
        return taskAddService.getTaskByName(staffIDList);
    }

    @RequestMapping(value="/add_task",method = RequestMethod.POST,produces = "application/json; charset=utf-8")
    public String addTask(@RequestBody(required = false) AddTaskGetDto addTaskGetDto, HttpServletRequest request){
        return taskAddService.addTask(addTaskGetDto,request);
    }

    @RequestMapping(value="/queryTaskDetailByCode",method = RequestMethod.POST,produces = "application/json; charset=utf-8")
    public String queryTaskDetailByCode(@RequestBody SupervisionTaskDetailInDto supervisionTaskDetailInDto){
        //只要传过来的supervisionTaskCode
        return taskAddService.queryTaskDetailByCode(supervisionTaskDetailInDto.getSupervisionTaskCode());
    }

    @RequestMapping(value="/manage_task",method = RequestMethod.POST,produces = "application/json; charset=utf-8")
    public String manageTask(@RequestBody SupervisionTaskDetailInDto supervisionTaskDetailInDto){
        return taskAddService.manageTask(supervisionTaskDetailInDto.getSupervisionTaskCode(),supervisionTaskDetailInDto.getTaskType(),supervisionTaskDetailInDto.getAreaName());
    }

    @RequestMapping(value="/addNewTask",method = RequestMethod.POST,produces = "application/json; charset=utf-8")
    public String addNewTask(@RequestBody AddTaskGetDto addTaskGetDto){
        return taskAddService.addNewTask(addTaskGetDto);
    }

}
